package {{.tf.Package}};
{{- $tfModel := ""}}
{{- $tfService := ""}}
{{- $tfMapper := ""}}
{{- $tfDto := ""}}
{{- range .tplFiles}}
{{- if eq .Type "Model"}}{{$tfModel = .}}{{- end}}
{{- if eq .Type "Service"}}{{$tfService = .}}{{- end}}
{{- if eq .Type "Mapper"}}{{$tfMapper = .}}{{- end}}
{{- if eq .Type "Dto"}}{{$tfDto = .}}{{- end}}
{{- end}}

{{- $model := toCamel .table.Name}}{{- /*Mode名字*/}}
{{- $lowerModel := toCamelLower .table.Name}}{{- /*Mode名字*/}}
{{- $mapper := printf "%sMapper" $model }}{{- /*Mapper*/}}
{{- $service := printf "I%sService" $model }}{{- /*接口*/}}
{{- $controller := printf "%sController" $model }}{{- /*controller*/}}
{{- .ctx.Set "fileName" $controller}}{{- /* 设置输出文件名字 */}}

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.travel.customized.dto.ResultDTO;
import com.travel.customized.entity.PageList;
import {{$tfDto.Package}}.*;
import {{$tfService.Package}}.{{$service}};
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;
import java.util.List;

/**
 * {{.table.Comment}} 前端控制器
 *
 * @author {{.tpl.Author}}
 * @since {{.datetime}}
 */
@Api(tags = "{{.table.Comment}}")
@ApiSupport(order = 0)
@RestController
@RequestMapping("{{- if and (ne .tf.Ext.module nil) (ne .tf.Ext.module "")}}/{{- .tf.Ext.module}}{{- end}}/{{$lowerModel}}")
public class {{$model}}Controller {
    @Resource
    private {{$service}} {{$lowerModel}}Service;

    @PostMapping("/list")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "{{- .table.Comment}}列表")
    public ResultDTO<List<{{$model}}ListRspDTO>> list(@RequestBody @Validated {{$model}}ListReqDTO dto) {
        return {{$lowerModel}}Service.list(dto);
    }

    @PostMapping("/listPage")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "{{- .table.Comment}}列表分页")
    @ApiImplicitParams(value = {
	    @ApiImplicitParam(name = "page", value = "页数"), @ApiImplicitParam(name = "pageSize", value = "分页大小"),
    })
    public ResultDTO<PageList<{{$model}}ListRspDTO>> listPage(Integer page, Integer pageSize, @RequestBody @Validated {{$model}}ListReqDTO dto) {
        return  {{$lowerModel}}Service.listPage(page, pageSize, dto);
    }

    @PostMapping("/add")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "{{- .table.Comment}}添加")
    public ResultDTO<{{$model}}AddRspDTO> add(@RequestBody @Validated {{$model}}AddReqDTO dto) {
		return  {{$lowerModel}}Service.add(dto);
    }

    @PostMapping("/update")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "{{- .table.Comment}}修改")
    public ResultDTO<{{$model}}UpdRspDTO> update(@RequestBody @Validated {{$model}}UpdReqDTO dto) {
		return  {{$lowerModel}}Service.update(dto);
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "{{- .table.Comment}}删除")
    public ResultDTO<{{$model}}DelRspDTO> delete(@RequestBody @Validated {{$model}}DelReqDTO dto) {
		return  {{$lowerModel}}Service.delete(dto);
    }
}
